﻿<phone:PhoneApplicationPage xmlns:ig="clr-namespace:Infragistics.Controls.Interactions;assembly=InfragisticsWP7.Controls.Interactions.XamRating.v11.2"  xmlns:my="clr-namespace:Microsoft.Phone.Controls.Maps;assembly=Microsoft.Phone.Controls.Maps"  
    x:Class="MyMeetup.EventPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls" FontFamily="{StaticResource PhoneFontFamilyNormal}"
    xmlns:toolbox="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WP71"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="696" d:DesignWidth="480"
    shell:SystemTray.IsVisible="True" shell:SystemTray.Opacity="0"
    xmlns:MyMeetup="clr-namespace:MyMeetup"
    DataContext="{Binding EventPageViewModel, Source={StaticResource Locator}}">

    <UserControl.Resources>
        <MyMeetup:GuestCountConverter x:Key="GuestCountConverter" />
    </UserControl.Resources>


    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Loaded">
            <cmd:EventToCommand Command="{Binding LoadedCommand}" />
        </i:EventTrigger>
    </i:Interaction.Triggers>
    
    
    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <controls:Pivot Title="{Binding Model.name}" Name="eventPivot" SelectionChanged="eventPivot_SelectionChanged">
            
            <!--Pivot item one-->
            <controls:PivotItem Header="summary">
                <ScrollViewer>
                    <StackPanel Margin="0,0,0,12">

                    <my:Map CredentialsProvider="AkC2fgKfyTcB6naEN_AbUtPme7dRNvmlq91QEai9W5HDC9uCLGvfcqwKJJ2adZOV" Center="{Binding MapCenter}"  Name="map1" Height="250" Margin="0,12,0,12" ZoomLevel="{Binding Zoom}">
                        <my:Pushpin Location="{Binding MapCenter}" Visibility="{Binding PushPinVisibility}" Template="{StaticResource PushpinControlTemplate2}" />
                    </my:Map>
                    <HyperlinkButton HorizontalAlignment="Right" Content="larger map" Name="mapLink"/>

                    <StackPanel Orientation="Horizontal" Margin="0,12,0,12">
                            <Rectangle Fill="{StaticResource PhoneForegroundBrush}" Width="48" Height="48" VerticalAlignment="top">
                                <Rectangle.OpacityMask>
                                    <ImageBrush ImageSource="/Images/location.png"/>
                                </Rectangle.OpacityMask>
                            </Rectangle>
                            <!--<Image Source="/Images/location.png" Stretch="None" VerticalAlignment="Top"/>-->

                            <StackPanel Orientation="Vertical">
                            <TextBlock Text="{Binding Model.venue.name}" TextWrapping="Wrap"/>
                            <TextBlock Text="{Binding Model.venue.address_1}"/>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="{Binding Model.venue.city}"/>
                                <TextBlock Text=" "/>
                                <TextBlock Text="{Binding Model.venue.StateZip}"/>
                            </StackPanel>
                        </StackPanel>

                    </StackPanel>


                    <StackPanel Orientation="Horizontal" Margin="0,12,0,12">
                            <Rectangle Fill="{StaticResource PhoneForegroundBrush}" Width="48" Height="48" VerticalAlignment="Top">
                                <Rectangle.OpacityMask>
                                    <ImageBrush ImageSource="/Images/calendar.png"/>
                                </Rectangle.OpacityMask>
                            </Rectangle>


                            <StackPanel Orientation="Vertical">
                            <TextBlock Text="{Binding Model.Date}"/>
                            <TextBlock Text="{Binding Model.Time}"/>
                        </StackPanel>
                    </StackPanel>
                    

                    <TextBlock Text="{Binding Model.venue.phone}"/>


                    
                        <StackPanel Orientation="Vertical">
                            <TextBlock Text="How to find us:"/>
                            <TextBlock Text="{Binding Model.how_to_find_us}" TextWrapping="Wrap"/>
                        </StackPanel>
                   </StackPanel>
                </ScrollViewer>
            </controls:PivotItem>
            
            <controls:PivotItem Header="description">
                <ScrollViewer>
                    <StackPanel>
                        <TextBlock Text="{Binding Model.description}" TextWrapping="Wrap"/>
                    </StackPanel>
                </ScrollViewer>

            </controls:PivotItem>
            
            <controls:PivotItem Header="rsvp" x:Name="rsvpView">
                <StackPanel>
                    <Border Padding="0,0,0,20">
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="Current RSVP: " FontSize="28"  />
                            <TextBlock Name="myrsvp" Text="{Binding Rsvp}" FontSize="28" />
                        </StackPanel>
                    </Border>
                    
                    <StackPanel Orientation="Vertical">
                        
                        
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="Guests:" VerticalAlignment="Center"/>
                            <TextBox Name="guests" IsReadOnly="True"  Text="{Binding MyGuests}" Width="80" TextAlignment="Center" />
                            <Button Content="-" Command="{Binding RemoveGuest}" Width="70"/>
                            <Button Content="+" Command="{Binding AddGuest}" Width="70"/>

                        </StackPanel>

                        <TextBlock Text="Comments:"/>
                        <TextBox Text="{Binding Comments, Mode=TwoWay}" Height="150" />

                    </StackPanel>
                    
                    <StackPanel Name="rsvp" Orientation="Horizontal">
                        <Button Content="Yes" Command="{Binding RsvpYesCommand}"/>
                        <Button Content="No" Command="{Binding RsvpNoCommand}" />
                    </StackPanel>

                    <StackPanel Name="checkin" Visibility="Collapsed">
                        <!--<Button Content="Checkin" Click="checkin_Click"/>-->
                    </StackPanel>

                </StackPanel>
            </controls:PivotItem>
            
            <controls:PivotItem Header="reviews" x:Name="rateView">
               <ScrollViewer >
                    <StackPanel>
                        <ItemsControl ItemsSource="{Binding CurrentEventRatings}" Margin="12,0,0,0">
                            <ItemsControl.ItemTemplate>
                                <DataTemplate>
                                    <StackPanel Margin="0,24,12,24">
                                        <TextBlock Text="{Binding review}" TextWrapping="Wrap" />
                                        <TextBlock Text="{Binding member_name}" FontSize="{StaticResource PhoneFontSizeSmall}" Foreground="Gray"/>
                                    </StackPanel>
                                </DataTemplate>
                            </ItemsControl.ItemTemplate>
                        </ItemsControl>
                    </StackPanel>
                </ScrollViewer>
            </controls:PivotItem>
            

            
            <controls:PivotItem Header="who's going?">
                <ListBox Margin="0,0,0,0" ItemsSource="{Binding Attendees}" ItemContainerStyle="{StaticResource SingleItemList}" SelectedItem="{Binding SelectedAttendee, Mode=TwoWay}">

                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="Tap">
                            <cmd:EventToCommand Command="{Binding MemberPageCommand, Mode=OneWay}"/>
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                    
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                           
                            <StackPanel Orientation="Horizontal">
                                <Image Source="{Binding member_photo.thumb_link}" VerticalAlignment="Top" Height="60" Width="60" Stretch="UniformToFill"/>
                                <StackPanel VerticalAlignment="Top" Orientation="Vertical">
                                    <StackPanel Orientation="Horizontal">
                                        <TextBlock Text="{Binding member.Name}" Padding="10,0,0,0" FontSize="{StaticResource PhoneFontSizeMediumLarge}" />
                                        <TextBlock Text="{Binding Guests, Converter={StaticResource GuestCountConverter}}" Padding="10,0,0,0" FontSize="{StaticResource PhoneFontSizeSmall}" VerticalAlignment="Center"/>
                                    </StackPanel>
                                    <TextBlock Width="300" Text="{Binding Comments}" TextWrapping="Wrap" Padding="10,0,0,0" FontSize="{StaticResource PhoneFontSizeSmall}" Foreground="Gray" />
                                </StackPanel>

                            </StackPanel>
                                
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>

            </controls:PivotItem>
            
            
            <controls:PivotItem Name="eventPhotos" Header="photos">
                <ScrollViewer>
                    <ScrollViewer>
                        <ItemsControl Name="Thumbnails" ItemsSource="{Binding Photos}">
                            <ItemsControl.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <toolbox:WrapPanel ItemWidth="110" ItemHeight="110"/>
                                </ItemsPanelTemplate>
                            </ItemsControl.ItemsPanel>
                            <ItemsControl.ItemTemplate>
                                <DataTemplate>
                                    <Button Style="{StaticResource ImageButton}"  Click="ImageClick">
                                        <Button.Content>
                                            <StackPanel>
                                                <Image Source="{Binding thumb_link}" Width="110" Height="110" Stretch="UniformToFill"/>
                                            </StackPanel>
                                        </Button.Content>
                                    </Button>
                                </DataTemplate>
                            </ItemsControl.ItemTemplate>

                        </ItemsControl>
                    </ScrollViewer>
                </ScrollViewer>
            </controls:PivotItem>


        </controls:Pivot>

    </Grid>

    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" x:Name="appBar" IsMenuEnabled="True">
            <!--<shell:ApplicationBarIconButton IconUri="/Images/appbar.add.rest.png" Text="add" Click="AddPhoto"/>-->
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

</phone:PhoneApplicationPage>
